
module.exports = app => {

    return class CollectController extends app.Controller {

        async index() {
            await this.ctx.render('member/collect/index.js');
        }

        async detail() {
            await this.ctx.render('member/grow/detail/index.js');
        }

        async list() {
            let params = this.ctx.request.query;
            let data = await this.ctx.service.collect.list(params);
            this.success(data)
        }

        /**
         * 删除收藏
         * @returns {Promise<void>}
         */
        async cancel() {
            let params = this.ctx.request.query;

            let id = params.id;

            await this.ctx.service.collect.cancel({
                ids: id
            });

            this.success();

        }


        async add() {
            let params = this.ctx.request.body;
            let data = await this.ctx.service.collect.add(params);
            this.success(data)
        }

    };
};
